package com.umanji.security.service;

import java.util.List;

import com.umanji.security.domain.Users;
import com.umanji.user.domain.Members;

import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.transaction.annotation.Transactional;

@PreAuthorize("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
public interface UserService {

    @PreAuthorize("hasRole('ROLE_USER')")
    @Transactional(value = "umanji", readOnly = false)
    void persist(Users entity);

    @PreAuthorize("hasRole('ROLE_USER')")
    @Transactional(value = "umanji", readOnly = true)
    Users findByUsername(String username);

    @PreFilter("filterObject.email == principal.username")
    @Transactional(value = "umanji", readOnly = false)
    void merge(Users entity);

    @PreAuthorize("hasRole('ROLE_USER')")
    @Transactional(value = "umanji", readOnly = false)
    void remove(Users entity);
/*
    @PreFilter("filterObject.email == principal.username")
    @Transactional
    void update(Users entity);
*/
    @Transactional(value = "umanji", readOnly = true)
    Users find(Long id);
}
